#!/bin/bash
set -e

echo $PATH

mkdir -p /data/mongo/shard3/shard3-5701{1,3,5,7}
mkdir -p /data/mongo/shard3/logs

mongod -f shard3/shard3-57011.conf
mongod -f shard3/shard3-57013.conf
mongod -f shard3/shard3-57015.conf
mongod -f shard3/shard3-57017.conf


mongo --port 57011 << EOF
use admin 
var cfg ={"_id":"shard3", 
"protocolVersion": 1,
"members":[ 
    {"_id":1,"host":"172.17.0.4:57011"}, 
    {"_id":2,"host":"172.17.0.4:57013"}, 
    {"_id":3,"host":"172.17.0.4:57015"},
    {"_id":4,"host":"172.17.0.4:57017","arbiterOnly":true}] 
};
rs.initiate(cfg)
rs.status()
EOF
